/**
 * Copyright (C) 2011 Denatics Development
 *
 * Programmed by David Tiersch <dtiersch@denatics.com>
 *
 * This file is part of B0mberman.
 *
 * B0mberman is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * B0mberman is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with B0mberman. If not, see <http://www.gnu.org/licenses/>.
 */
package com.denatics.bomberman.sprites;

import com.denatics.bomberman.control.PlayerControl;
import com.denatics.bomberman.control.PlayerControl.Type;
import com.denatics.bomberman.tools.Tickable;

/**
 * The figure of the player.
 *
 * @author David Tiersch <dtiersch@denatics.com>
 */
public final class Player extends Sprite implements Tickable {

    /**
     * ID of the Player.
     */
    private final int id;

    /**
     * Storage of the Controls.
     */
    private PlayerControl control;

    /**
     * Creates the Object and sets the properties to the target values.
     *
     * @param playerid
     *            Id of the Player
     */
    public Player(final int playerid) {
        this.id = playerid;
        this.control = new PlayerControl(playerid);
        setPadding(1);
    }

    /*
     * (non-Javadoc)
     *
     * @see com.denatics.bomberman.entities.Entity#getType()
     */
    @Override
    public SpriteType getType() {
        return SpriteType.PLAYER;
    }

    /*
     * (non-Javadoc)
     *
     * @see com.denatics.bomberman.sprites.Sprite#getTexPosition()
     */
    @Override
    public int[] getTexPosition() {
        int[] offset = {id, 0 };
        return offset;
    }

    /**
     * Checks if the key is associated with the Player and returns it function.
     *
     * @param keyid
     *            Id of the key to check
     *
     * @return the function for this key (else null)
     */
    public Type checkKey(final int keyid) {
        return this.control.getElement(keyid);
    }

    /*
     * (non-Javadoc)
     *
     * @see com.denatics.bomberman.tools.Tickable#tick()
     */
    @Override
    public void tick() {
        /*
         * int[] offset = this.getOffset();
         * for (int i = 0; i < offset.length; i++) {
         * if (offset[i] != 0) {
         * offset[i] = offset[i] - (offset[i] / Math.abs(offset[i]));
         * }
         * }
         * this.setOffset(offset[0], offset[1]);
         */
    }
}
